package com.example.demo.controller;
/**
 * @Author Justice
 * @Date 2019/4/8 16:17
 * @Version 1.0
 */

import com.alibaba.fastjson.JSON;
import com.example.demo.mapper.UserMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
public class DbController {


  @Resource
  private JdbcTemplate jdbcTemplate;

  @Resource
  private UserMapper userMapper;
   
  @RequestMapping("/u")
  public List<Map<String, Object>> getDbType(){
    String sql = "select * from sys_user";
    List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
    return list;
  }

  @RequestMapping("/c")
  public Integer count(){
    return userMapper.count();
  }

  @RequestMapping("/l")
  public Object list(){
    return JSON.toJSONString(userMapper.selectlist());
  }

}